import axios from 'axios';

const service = axios.create({
    // process.env.NODE_ENV === 'development' 来判断是否开发环境
    // easy-mock服务挂了，暂时不使用了
    // axios.defaults.baseURL = 'http://39.106.176.101:9999/api/'
    baseURL: 'http://82.157.177.113:9999',
    timeout: 5000,

});
let token = `eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHBpcmVUaW1lIjoxNjUzODE2MTUxMjM3LCJyb2xlSWQiOjIsInVzZXJOYW1lIjoiYWRtaW4iLCJ1c2VySWQiOjF9.zr2gqwSk4XseNb2gREoT0LKI7SU1mp9Id2qvcVrXdpM`;
service.interceptors.request.use(
    config => {
        config.headers.token = window.sessionStorage.getItem('token')
        return config;
    },
    error => {
        console.log(error);
        return Promise.reject();
    }
);

service.interceptors.response.use(
    response => {
        if (response.status === 200) {
            return response.data;
        } else {
            Promise.reject(response);
        }
    },
    error => {
        console.log(error);
        return Promise.reject(error);
    }
);




export default service;